package com.yyaccp.appinfo.service;

import com.yyaccp.appinfo.domain.BackendUser;
import com.yyaccp.appinfo.exception.LoginException;
import com.yyaccp.appinfo.mapper.BackendUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("backendUserService")
public class BackendUserService {

    @Autowired
    private BackendUserMapper backendUserMapper;

    public BackendUser backendLogin(BackendUser User) throws LoginException{
        BackendUser backendUser = backendUserMapper.selectByUserCode(User.getUserCode());
        if(backendUser == null){
            throw new LoginException("账号输入错误!");
        }
        if(!backendUser.getUserPassword().equals(User.getUserPassword())){
            throw new LoginException("密码输入错误!");
        }
        return backendUser;
    }
}
